package com.cskaoyan.weixin.service;

import com.cskaoyan.bean.User1;
import com.cskaoyan.bean.UserExample;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.weixin.bean.login.WxLoginVO1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WxAuthenticateServiceImpl implements WxAuthenticateService {

    @Autowired
    UserMapper userMapper;

    @Override
    public WxLoginVO1 getUserInfo(String username) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<User1> user1s = userMapper.selectByExample(userExample);
        User1 user = user1s.get(0);
        WxLoginVO1 wxLoginVO1 = new WxLoginVO1();
        wxLoginVO1.setAvatarUrl(user.getAvatar());
        wxLoginVO1.setNickName(user.getNickname());
        return wxLoginVO1;
    }
}
